package com.enjoyor.health.HGPT.web.rest;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.enjoyor.health.HGPT.core.entity.News;
import com.enjoyor.health.HGPT.core.entity.SelftestContent;
import com.enjoyor.health.HGPT.service.BizSelfTestService;
import com.enjoyor.health.HGPT.web.RetResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Zhu Min
 * @date 2023/12/13 10:06
 */
@Api(value = "自测页面", tags = {"Web页面管理接口"})
@CrossOrigin
@RequestMapping("/rest")
@RestController
public class WebSelfTestController {

    @Autowired
    private BizSelfTestService bizSelfTestService;

    @ApiImplicitParams({
            @ApiImplicitParam(name = "title", value = "标题"),
            @ApiImplicitParam(name = "state", value = "类型：图文、视频"),
            @ApiImplicitParam(name = "page", value = "页码，不为空"),
            @ApiImplicitParam(name = "size", value = "每页条数，不为空")})
    @RequestMapping(value = "/selfTest/getPage", method = { RequestMethod.GET, RequestMethod.POST })
    public RetResult getSelfTestPage(
            String title,
            String state,
            @RequestParam(required = true, defaultValue = "1") int page,
            @RequestParam(required = true, defaultValue = "10")int size){
        Page<SelftestContent> newsPage = bizSelfTestService.getSelfTestContentPage(title, state, page, size);
        return new RetResult().setResult(newsPage);
    }

    @RequestMapping(value = "/selfTest/getById", method = { RequestMethod.GET, RequestMethod.POST })
    public RetResult getSelfTestById(String id){
        //TODO
        return null;
    }

}
